package com.tc168.cp306.b06.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.tc168.cp306.b06.MyApplication;
import com.tc168.cp306.b06.R;
import com.tc168.cp306.b06.adaptre.Answer_userAdapter;
import com.tc168.cp306.b06.bean.UserAnswerbean;
import com.tc168.cp306.b06.gen.UserAnswerbeanDao;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TIJIActivity extends AppCompatActivity {

    @BindView(R.id.back_ig)
    ImageView backIg;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.rv)
    RecyclerView anRv;



    private List<UserAnswerbean> mdata;
    private Answer_userAdapter answer_itemAdapter;
    private UserAnswerbeanDao topticbeanDao;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tiji);
        ButterKnife.bind(this);

        topticbeanDao = MyApplication.getmDaoSessiontwo().getUserAnswerbeanDao();


        mdata = new ArrayList<>();
        answer_itemAdapter = new Answer_userAdapter(TIJIActivity.this, mdata);

        anRv.setAdapter(answer_itemAdapter);
        anRv.setLayoutManager(new LinearLayoutManager(TIJIActivity.this));

        answer_itemAdapter.setOnItemClickListener(new Answer_userAdapter.MyItemClickListener() {
            @Override
            public void onItemClick(View view, int postion) {
                Intent intent = new Intent(TIJIActivity.this, CuoMatterActivity.class);
                intent.putExtra("num",postion);
                startActivity(intent);
            }
        });

        List<UserAnswerbean> list = topticbeanDao.queryBuilder().where(UserAnswerbeanDao.Properties.Istrue.eq(false)).list();
        mdata.addAll(list);
        answer_itemAdapter.notifyDataSetChanged();
    }

    @OnClick(R.id.back_ig)
    public void onViewClicked() {
        finish();
    }
}
